package net.board.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.board.db.BoardDAO;
import net.board.db.BoardBean;

public class BoardModifyView implements Action {
	 public ActionForward execute(HttpServletRequest request,HttpServletResponse response) throws Exception{
		 	ActionForward forward = new ActionForward();
		 	
		 	request.setCharacterEncoding("UTF-8");
			response.setCharacterEncoding("UTF-8");
			response.setContentType("text/html; charset=UTF-8");
	   		
			BoardDAO boarddao=new BoardDAO();
		   	BoardBean boarddata=new BoardBean();
		   	String url;
		   	int number = Integer.parseInt(request.getParameter("number"));

		   	if(number == 1){
		   		url = "/Main/OldMain/Om_Main.jsp";
		   	}else if(number == 3){
		   		url = "/Main/admin/Ad_Main.jsp";
		   	}
		   	else{
		   		url = "/Main/YoungMain/Ym_Main.jsp";
		   	}
			int ID=Integer.parseInt(request.getParameter("ID"));
		   	boarddata=boarddao.getDetail(ID);
		   	
		   	if(boarddata==null){
		   		return null;
		   	}
		   	request.setAttribute("boarddata", boarddata);
		   	forward.setRedirect(false);
	   		String pagename = "/board/qna_board_modify";
			request.setAttribute("page", pagename);
			request.setAttribute("number", number);
		   	
	   		forward.setPath(url);
	   		return forward;
	 }
}